<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>JSX</title>
    <script src="./js/react.development.js"></script>
    <script src="./js/react-dom.development.js"></script>
    <script src="./js/babel.min.js"></script>
    <style>
      header{
        height: 100px;
        background: #fee;
      }
      main{
        height: 400px;
        background: #efe;
      }
      footer{
        height: 100px;
        background: #eef;
      }
    </style>
  </head>
  <body>
    <div id="root"></div>
    <script type="text/babel">
      //组件函数名字首字母一定要大写
      function Header(){
        return <header>头部</header>;
      }
      //内容区
      function Content(){
        return <main>主体内容</main>
      }
      //尾部区域
      let Footer = () => <footer>尾部</footer>;

      //创建虚拟 DOM 对象. React 渲染组件的时候, 会找与标签名同名的函数, 调用函数获得虚拟 DOM 对象, 再进行渲染 
      function App(){
        return <div>
          <Header></Header>
          <Content></Content>
          <Footer />
        </div>
      }

      //渲染  React.createElement('h2', null, 'test')
      // console.log(<h2>test</h2>);
      // console.log(<App />);
      ReactDOM.render(<App />, document.querySelector('#root'))
    </script>
  </body>
</html>
